﻿<Window x:Class="Wpf.Explorations.TestApplication.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:local="clr-namespace:Wpf.Explorations.TestApplication"
	xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
	xmlns:e="http://schemas.exploration.com/xaml/presentation" Width="523" Height="725" WindowStartupLocation="CenterScreen">
	<Window.Resources>
		<CollectionViewSource x:Key="StandardCollectionView" Source="{x:Static local:PersonViewModel.People}">
			<CollectionViewSource.GroupDescriptions>
				<PropertyGroupDescription PropertyName="Category" />
				<PropertyGroupDescription PropertyName="Gender" />
			</CollectionViewSource.GroupDescriptions>
			<CollectionViewSource.SortDescriptions>
				<scm:SortDescription PropertyName="Age" />
			</CollectionViewSource.SortDescriptions>
		</CollectionViewSource>
		<CollectionViewSource x:Key="ActiveGroupingCollectionView" Source="{x:Static local:PersonViewModel.People}" CollectionViewType="{x:Type e:ActiveGroupingCollectionView}">
			<CollectionViewSource.GroupDescriptions>
				<PropertyGroupDescription PropertyName="Category" />
				<PropertyGroupDescription PropertyName="Gender" />
			</CollectionViewSource.GroupDescriptions>
			<CollectionViewSource.SortDescriptions>
				<scm:SortDescription PropertyName="Age" />
			</CollectionViewSource.SortDescriptions>
		</CollectionViewSource>
		<Style TargetType="{x:Type ListView}" x:Key="ListViewStyle">
			<Setter Property="BorderBrush" Value="Transparent" />
			<Setter Property="Margin" Value="5" />
			<Setter Property="HorizontalContentAlignment" Value="Stretch" />
			<Setter Property="ItemTemplate">
				<Setter.Value>
					<DataTemplate>
						<local:PersonControl />
					</DataTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<GroupStyle x:Key="GroupStyle">
			<GroupStyle.ContainerStyle>
				<Style TargetType="{x:Type GroupItem}">
					<Setter Property="Template">
						<Setter.Value>
							<ControlTemplate TargetType="{x:Type GroupItem}">
								<Expander IsExpanded="True" BorderBrush="Gray" Margin="1">
									<Expander.Header>
										<TextBlock>
											<TextBlock.Text>
												<MultiBinding StringFormat="{}{0} - ({1})">
													<Binding Path="Name" />
													<Binding Path="ItemCount" />
												</MultiBinding>
											</TextBlock.Text>
										</TextBlock>
									</Expander.Header>
									<ItemsPresenter />
								</Expander>
							</ControlTemplate>
						</Setter.Value>
					</Setter>
				</Style>
			</GroupStyle.ContainerStyle>
		</GroupStyle>
	</Window.Resources>
	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition />
		</Grid.RowDefinitions>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="196*" />
			<ColumnDefinition Width="201.5*" />
		</Grid.ColumnDefinitions>
		<TextBlock Grid.Column="0" Grid.Row="0" Text="Standard CollectionView" Margin="2" />
		<TextBlock Grid.Column="1" Grid.Row="0" Text="ActiveGroupingCollectionView" Margin="7.253,2,2,2" />
		<ListView Grid.Column="0" Grid.Row="1" Style="{StaticResource ListViewStyle}" ItemsSource="{Binding Source={StaticResource StandardCollectionView}}">
			<ListView.GroupStyle>
				<StaticResource ResourceKey="GroupStyle" />
			</ListView.GroupStyle>
		</ListView>
		<GridSplitter HorizontalAlignment="Left" ShowsPreview="True" Background="Black" Grid.Row="0" Grid.Column="1" Width="5" Grid.RowSpan="2" Focusable="False" SnapsToDevicePixels="True" Padding="2" Cursor="SizeWE" FocusVisualStyle="{x:Null}" Margin="0.253,0,0,0" />
		<ListView Grid.Column="1" Grid.Row="1" Style="{StaticResource ListViewStyle}" ItemsSource="{Binding Source={StaticResource ActiveGroupingCollectionView}}" Margin="10.253,5,5,5">
			<ListView.GroupStyle>
				<StaticResource ResourceKey="GroupStyle" />
			</ListView.GroupStyle>
		</ListView>
	</Grid>
</Window>
